package com.sunday.android.fangdaifu.bukong;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;


import com.sunday.android.fangdaifu.bukong.activity.login.LoginActivity;
import com.sunday.android.fangdaifu.bukong.utils.Constants;
import com.sunday.android.fangdaifu.bukong.utils.StatusBarUtil;
import com.sunday.member.base.BaseActivity;
import com.sunday.member.utils.SharePerferenceUtils;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by Administrator on 2016/3/3.
 */
public class SplashActivity extends BaseActivity {
    @Bind(R.id.splash_image)
    ImageView splashView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);
        StatusBarUtil.setTransparentForImageView(this , null);

        AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
        animation.setDuration(2000);
        splashView.startAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                boolean isLogin = SharePerferenceUtils.getIns(mContext).getBoolean(Constants.IS_LOGIN, false);
                boolean isFirst = SharePerferenceUtils.getIns(mContext).getBoolean(Constants.IS_FIRST,true);
                if(!isLogin){
                    intent = new Intent(mContext, LoginActivity.class);
                }else{
                    intent = new Intent(mContext, MainActivity.class);
                }
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        //getData();
    }

//    private void getData(){
//        Call<ResultDO> call = HttpClient.getHttpAdapter().guide01(null);
//        call.enqueue(new Callback<ResultDO>() {
//            @Override
//            public void onResponse(Call<ResultDO> call, Response<ResultDO> response) {
//                if(response.body() == null || isFinish){
//                    return;
//                }
//                if(response.body().getCode() == 0 &&response.body().getResult() != null){
//                    int width  = DeviceUtils.getDisplay(mContext).widthPixels;
//                    int height = DeviceUtils.getDisplay(mContext).heightPixels;
//                    String image = response.body().getResult().toString().substring(1,response.body().getResult().toString().length()-1);
//                    Picasso.with(mContext).load(NoUtil(image, ""))
//                            .resize(width,height)
//                            .memoryPolicy(NO_CACHE, NO_STORE)
//                            .config(Bitmap.Config.RGB_565)
//                            .into(splashView);
//                    Log.d("aaaa" , NoUtil(image , ""));
//                }
//            }
//
//            @Override
//            public void onFailure(Call<ResultDO> call, Throwable t) {
//
//            }
//        });
//    }

}
